﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
    public class HoaDonDAO : AbstractDAO
    {
        public List<HoaDonDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM HoaDon";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<HoaDonDTO> dsHoaDon = new List<HoaDonDTO>();
            HoaDonDTO s;
            while (reader.Read())
            {
                s = new HoaDonDTO();
                s.MaHoaDon = reader.GetInt32(0);
                s.MaKhachHang = reader.GetInt32(1);
                s.NgayLapHoaDon = reader.GetDateTime(2);
                s.TongTien = reader.GetDouble(3);
                s.TinhTrang = reader.GetBoolean(4);
                dsHoaDon.Add(s);
            }
            Close(connection);
            return dsHoaDon;
        }
    }
}
